<template>
  <el-table :data="tableData" border style="width: 80%" class="m-auto">
    <el-table-column fixed prop="upload_date" label="日期" width="150">
    </el-table-column>
    <el-table-column prop="name" label="物品名" width="120"> </el-table-column>
    <el-table-column prop="prise" label="价格" width="120">
    </el-table-column>
    <el-table-column prop="describe" label="简介" width="120"> </el-table-column>
    <el-table-column prop="photo_url" label="简介" width="120"> </el-table-column>
    <el-table-column label="操作" width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small"
          >查看</el-button
        >
        <el-button type="text" size="small">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<style scoped>
.m-auto{
  margin: 0 auto;
}
</style>
<script>
export default {
  methods: {
    handleClick(row) {
      console.log(row);
    },
  },

  data() {
    return {
      tableData: [],
    };
  },
  mounted(){
  // 发送axios请求获取商品列表
this.$axios.get("/products/index").then(res=>{
  res.data.forEach(element => {
    element.upload_date = this.moment(element.upload_date).format('YY-M-D H:m:s'); 
  });
  this.tableData = res.data;
});
  }
};
</script>